package cn.edu.scau.cmi.huangxiaodong.comprehensive;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ResourceBundle;
import java.util.Scanner;

import cn.edu.scau.cmi.huangxiaodong.interProgramming.GraduateStudent;
import cn.edu.scau.cmi.huangxiaodong.interProgramming.Student;
import cn.edu.scau.cmi.huangxiaodong.interProgramming.UndergraduateStudent;
import javafx.application.Application;

public class ComprehensiveController  implements Initializable{
	@FXML
    private StackPane picture;


	 @Override
	    public void initialize(URL location, ResourceBundle resources) {
			Image image = new Image("picture.jpg");
			ImageView imageView = new ImageView();
			imageView.setImage(image);
			imageView.setFitHeight(480);
			imageView.setFitWidth(400);
			picture.getChildren().add(imageView);
			picture.setAlignment(Pos.TOP_LEFT);     // 在堆栈面板中右对齐
			
	 }
    public void basic()throws  Exception {//实验基础
    	
    	  Alert alert = new Alert(Alert.AlertType.INFORMATION);
          alert.setTitle("提示对话框");
          alert.setContentText("请看控制台");
          alert.showAndWait();
          
        Student student;
        student=new GraduateStudent();
       student.learning();
       student=new UndergraduateStudent();
        student.learning();
    }
	
	public void singletonAndManyCases() throws Exception {//单例和多例模式
		SingletonController singletonController=  new SingletonController();
		singletonController.start();
	  }
	
	 public void simpleFactoryMethod() throws Exception {//简单工厂方法
		  Alert alert = new Alert(Alert.AlertType.INFORMATION);
          alert.setTitle("提示对话框");
          alert.setContentText("请看控制台");
          alert.showAndWait();         
          clearConsole();
          SimpleFactoryMethodController.start();
	
	  }
	
	 public void factory() throws Exception {//工厂模式
		  Alert alert = new Alert(Alert.AlertType.INFORMATION);
          alert.setTitle("提示对话框");
          alert.setContentText("请看控制台");
          alert.showAndWait();          
       FactoryController.start();
	  }
	 
	 public void abstractFactory() throws Exception {//抽象工厂
		  Alert alert = new Alert(Alert.AlertType.INFORMATION);
          alert.setTitle("提示对话框");
          alert.setContentText("请看控制台");
          alert.showAndWait();          
          
          AbstractFactoryController.start();
          
	  }
	 
	 public void objectAdapter() throws Exception {//对象适配器
		 Stage  primaryStage=new Stage();
	       primaryStage.setTitle("对象适配器模式");
		      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/cn/edu/scau/cmi/huangxiaodong/adapter/AdapaterOfObject.fxml"));
		        Parent root = fxmlLoader.load();
		        Scene scene = new Scene(root);	      
		        primaryStage.setMaximized(true);	 
		        primaryStage.setScene(scene);
		        primaryStage.show();
	  }
	 
	 public void classAdapter() throws Exception {//类适配器
		 Stage  primaryStage=new Stage();
	       primaryStage.setTitle("类适配器模式");
		      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/cn/edu/scau/cmi/huangxiaodong/adapter/AdapaterOfClass.fxml"));
		        Parent root = fxmlLoader.load();
		        Scene scene = new Scene(root);	      
		        primaryStage.setMaximized(true);	 
		        primaryStage.setScene(scene);
		        primaryStage.show();
	  }
	 	 
	 public void safeComposite() throws Exception {//安全性组合
		 SafeCpmpositeController safeCpmpositeController=new SafeCpmpositeController();
		 safeCpmpositeController.start();
	  }
	 
	 public void consistentComposite() throws Exception {//一致性组合
		 ConsistentCompositeController consistentCompositeController=new ConsistentCompositeController();
		 consistentCompositeController.start();
	  }
	 
	 public void mybaits() throws Exception {//mybatis框架
		   FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Mybatis.fxml"));
		      Parent root = fxmlLoader.load();		        
		     Stage stage=new Stage();
		        Scene scene = new Scene(root,800,550);
		       stage.setMaximized(false); 
		        stage.setScene(scene);
		        stage.show();
	 }
	 
	 public void springSingletonApplicationContext() throws Exception{//Spring基本使用
		  Alert alert = new Alert(Alert.AlertType.INFORMATION);
          alert.setTitle("提示对话框");
          alert.setContentText("请看控制台");
          alert.showAndWait();
          
          SpringSingletonApplicationContextController.start();
	 }
	 
	 public void springBaits() throws Exception{//Mybaits+DAO
		 FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/springMybatis.fxml"));		
		      Parent root = fxmlLoader.load();		        
		     Stage stage=new Stage();
		        Scene scene = new Scene(root,800,550);
		       stage.setMaximized(false); 
		        stage.setScene(scene);
		        stage.show();
	 }
	 
	 private static void clearConsole()
	 {
	     try
	     {
	         String os = System.getProperty("os.name");

	         if (os.contains("Windows"))
	         {
	             Runtime.getRuntime().exec("cls");
	         }
	         else
	         {
	             Runtime.getRuntime().exec("clear");
	         }
	     }
	     catch (Exception exception)
	     {
	         //  Handle exception.
	     }
	 }


}
